/*
 * @lc app=leetcode.cn id=1758 lang=cpp
 *
 * [1758] 生成交替二进制字符串的最少操作数
 */

// @lc code=start
class Solution {
public:
    int minOperations(string s) {
        int n = s.size(), cnt = 0;
        for (int i = 0; i < n; i++) {
            char c = s[i];
            if (c != (char)('0' + (i & 1))) {
                cnt++;
            }
        }
        return min(cnt, n - cnt);
    }
};
// @lc code=end
